#include <stdio.h>
#include <setjmp.h>

jmp_buf env;
int div2num (int a, int b);
int main (void)
{
	//实现两个数的除法运算
	int num1, num2;
	//如果除数为0,要跳转的位置
	if (0 == setjmp (env)) {
		//第一次跳转, 非longjmp跳转过来
		printf ("please input two numbers:");
	} else {
		//不是0, 则一定跳转过来的
		printf ("please input numbers again:");
	}
	scanf ("%d%d", &num1, &num2);
	printf ("%d\n", div2num(num1, num2));
	return 0;
}

int div2num (int a, int b)
{
	if (0 == b) {
		//设置一个跳转的位置
		longjmp (env, 1);
	}
	return a / b;
}

